﻿using ConfigService;
using System;
using System.Collections.Generic;

namespace LayeredConfig
{
    public class LayereCfg : ILayeredConfigInterface
    {
        private readonly IEnumerable<IConfigService> _configServices;

        public LayereCfg(IEnumerable<IConfigService> configServices)
        {
            this._configServices = configServices;
        }

        public string GetValue(string name)
        {
            string resultStr = string.Empty;
            //此处为啥用forEach
            foreach (IConfigService config in _configServices)
            {
                if (config==null)
                {
                    continue;
                }
                resultStr = config.GetValue(name);
            }
            return resultStr;
        }
    }
}
